package cn.fzkj.lifecircle02;

import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.actor.Props;

/**
 * @ author mr
 * @ description
 * @ since 2024/12/2
 */
public class Main0201 {

    public static void main(String[] args) {
        ActorSystem actorSystem = ActorSystem.create("system-actor");

        ActorRef superVisor = actorSystem.actorOf(Props.create(SuperVisor.class), "SuperVisor");
        superVisor.tell(Props.create(RestartActor.class), ActorRef.noSender());

        ActorSelection actorSelection = actorSystem.actorSelection("akka://strategy/user/SuperVisor/restartActor");//这是akka的路径。restartActor是在SuperVisor中创建的。

        for(int i = 0 ; i < 100 ; i ++){
            actorSelection.tell(RestartActor.Msg.RESTART, ActorRef.noSender());
        }
        actorSystem.terminate();
    }
}
